//MODBUS数据采集模块
#ifndef __MODBUS_UP_H__
#define __MODBUS_UP_H__
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <pthread.h>
#include <unistd.h>
#include <modbus.h>
#include <cJSON.h>
#include <file_opt.h>
#include <shmem.h>
#include <list.h>
#include <msg_queue_peer.h>
#include "same.h"

#define PORT "8888"         //端口号
#define ADDR "192.168.5.156" //ip
#define errDbug printf("%s %d\n", __func__, __LINE__);



struct modbus_data //共享内存
{
    float air_temp;
    float temperature;
    float humidity;
    int air_switch;
    int light;
};

struct msgbuf send_buf;
struct msgbuf recv_buf;

struct mb_node
{
    int key;        //唯一键值
    char name[128]; //数据点名称
    int type;       //数据点类型
    int addr;       //modbus地址
};

struct mb_node_list //缓存链表
{
    struct mb_node node;
    struct list_head list;
};
struct list_head head;
struct mb_node_list *new;

int modbus_init();
#endif